import React, { useState, useMemo } from "react";

export default () => {
  let [aa, setAa] = useState("123");
  let [bb, setbb] = useState("12xx");
  let resMemo = useMemo(() => {
    //   这里可以做判断 返回
    return { aa, bb };
  }, [aa,bb]); // 数组存放的东西就是会导致更新的 参数是会更新的 但不会渲染
  return (
    <div>
      <h1>useMemo</h1>
      <button
        onClick={(e) => {
          setAa(aa + "1233");
        }}
      >
        edit
      </button>
      {resMemo.aa}
      <br />
      <button
        onClick={(e) => {
          setbb(bb + "xzc");
        }}
      >
        bb edxit
      </button>
      <div>{resMemo.bb}</div>
    </div>
  );
};
